<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:68:"C:\wamp\www\back\public/../application/admin\view\user\userlist.html";i:1559551144;s:49:"C:\wamp\www\back\application\admin\view\base.html";i:1559565933;s:60:"C:\wamp\www\back\application\admin\view\public\sidemenu.html";i:1559564037;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>后台管理-用户管理</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="Bluth Company">
  <link rel="shortcut icon" href="/back/public/static/assets/ico/favicon.html">
  <link href="/back/public/static/assets/css/bootstrap.css" rel="stylesheet">
  <link href="/back/public/static/assets/css/theme.css" rel="stylesheet">
  <link href="/back/public/static/assets/css/font-awesome.min.css" rel="stylesheet">
  <link href="/back/public/static/assets/css/alertify.css" rel="stylesheet">

  <link rel="Favicon Icon" href="favicon.ico">
  <style type="text/css">
    .line-limit-length {
      width: 300px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  </style>
  <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>

<body>
  <div id="wrap">
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
          <div class="logo">
            <img src="/back/public/static/assets/img/logo.png" alt="Realm Admin Template">
          </div>
          <a class="btn btn-navbar visible-phone" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="btn btn-navbar slide_menu_left visible-tablet">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>

          <div class="top-menu visible-desktop">
            <ul class="pull-left">
              <!-- <li><a id="messages" data-notification="2" href="#"><i class="icon-envelope"></i> Messages</a></li> -->
              <!-- <li><a id="notifications" data-notification="3" href="#"><i class="icon-globe"></i> Notifications</a></li> -->
            </ul>
            <ul class="pull-right">
              <li><a href="<?php echo url('index/logout'); ?>"><i class="icon-off"></i> Logout</a></li>
            </ul>
          </div>

          <div class="top-menu visible-phone visible-tablet">
            <ul class="pull-right">
              <li><a title="link to View all Messages page, no popover in phone view or tablet" href="#"><i
                    class="icon-envelope"></i></a></li>
              <li><a title="link to View all Notifications page, no popover in phone view or tablet" href="#"><i
                    class="icon-globe"></i></a></li>
              <li><a href="login.html"><i class="icon-off"></i></a></li>
            </ul>
          </div>

        </div>
      </div>
    </div>

    <div class="container-fluid">
      
      <!-- Side menu -->
<div class="sidebar-nav nav-collapse collapse">
    <div class="user_side clearfix">
        <img src="/back/public/static/assets/img/odinn.jpg" alt="Odinn god of Thunder">
        <h5><?php echo \think\Session::get('adminName'); ?></h5>
        <a href="#"><i class="icon-cog"></i> Settings</a>
    </div>
    <div class="accordion" id="accordion2">
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_F79999" href="<?php echo url('types/index'); ?>"><i class="icon-book"></i> <span>商品分类维护</span></a>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_F79999" href="<?php echo url('comments/index'); ?>"><i class="icon-dashboard"></i> <span>评论维护</span></a>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_F6F1A2" href="<?php echo url('report/index'); ?>"><i class="icon-tasks"></i> <span>问题申述</span></a>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_C1F8A9" href="<?php echo url('goods/index'); ?>"><i class="icon-bar-chart"></i> <span>商品信息管理</span></a>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_9FDDF6" href="<?php echo url('school/index'); ?>"><i class="icon-bullhorn"></i> <span>学校管理</span></a>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle b_F5C294" href="<?php echo url('user/userlist'); ?>"><i class="icon-user"></i> <span>用户管理</span></a>
            </div>
        </div>
        {/if}
    </div>
</div>
<script>
    // $(function(){
    //     $(".accordion-toggle").on("click",function(){
    //         $(".accordion-toggle").removeClass("active");
    //         $(this).addClass("active");
    //     });
    // })
</script>
<!-- /Side menu -->



      
      <!-- Main window -->
      <div class="main_container" id="users_page">

        <div class="row-fluid">
          <ul class="breadcrumb">
            <!-- <li><a href="#">Home</a> <span class="divider">/</span></li>
            <li><a href="#">Pages</a> <span class="divider">/</span></li>
            <li class="active">Admin</li> -->
          </ul>
          <h2 class="heading">
              Admin: <?php echo \think\Session::get('admin'); ?>
            <div class="btn-group pull-right">
              <button class="btn"><i class="icon-download-alt"></i> Export</button>
              <button class="btn"><i class="icon-envelope"></i> Email</button>
              <button class="btn"><i class="icon-cog"></i> Settings</button>
            </div>
          </h2>
        </div> 
<!-- /row-fluid -->

        <div class="row-fluid">
          <div class="widget widget-padding span12">
            <div class="widget-header">
              <i class="icon-group"></i>
              <h5>admin</h5>
              <div class="widget-buttons">
                <a href="add.html" data-title="Add User" data-toggle="modal" data-target="#example_modal"><a
                    href="add.html"><i class="icon-plus"></i></a></a>
                <a href="#" data-title="Collapse" data-collapsed="false" class="collapse"><i
                    class="icon-chevron-up"></i></a>
              </div>
            </div>
            
<div class="widget-body">
    <div class="span6">
        <div id="users_length" class="dataTables_length">
            <label>Entries:
                <select size="1" name="users_length" aria-controls="users">
                    <option value="1" selected="selected">1</option>
                    <option value="2">2</option>
                    <option value="5">5</option>
                    <option value="10">10</option>
                </select>
            </label>
        </div>
    </div>
    <div class="span6">
        <div class="dataTables_filter" id="users_filter">
            <label>Search:
                <input type="text" aria-controls="users" name="Search">
            </label>
        </div>
    </div>
    <table id="user" class="table table-striped table-bordered dataTable">
        <thead>
            <tr>
                <th>昵称</th>
                <th>学号</th>
                <th>电话</th>
                <th>学校</th>
                <th>状态</th>
                <th></th>
            </tr>
        </thead>
        <tbody class="userlist">
            <?php if(is_array($usersa) || $usersa instanceof \think\Collection || $usersa instanceof \think\Paginator): $i = 0; $__LIST__ = $usersa;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
            <tr>
                <td><?php echo $vo['name']; ?></td>
                <td><?php echo $vo['sNumber']; ?></td>
                <td><?php echo $vo['teleNumber']; ?></td>
                <td><?php echo $vo['schoolName']; ?></td>
                <td>
                    <?php if($vo['status'] == 0): ?>
                    <span class="label label-success slabel" data-uid="<?php echo $vo['userId']; ?>" data-status='0'>正常</span>
                    <?php else: ?>
                    <span class="label slabel" data-uid="<?php echo $vo['userId']; ?>" data-status='1'>禁用</span>
                    <?php endif; ?>
                </td>
                <td>
                    <div class="btn-group">
                        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                            操作
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="<?php echo url('resetpw',['uid'=>$vo['userId']]); ?>"><i class="icon-wrench"></i> 重置密码</a>
                            </li>
                            <li><a href="<?php echo url('edituser',['uid'=>$vo['userId']]); ?>"><i class="icon-edit"></i> 修改</a></li>
                            <li><a href="<?php echo url('deluser',['uid'=>$vo['userId']]); ?>"><i class="icon-trash"></i> 删除</a></li>
                        </ul>
                    </div>
                </td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
    <div class="dataTables_paginate paging_bootstrap pagination">
        <ul name="pagelist" pagenum="<?php echo $all; ?>">
            <?php $__FOR_START_19717__=1;$__FOR_END_19717__=$all+1;for($i=$__FOR_START_19717__;$i < $__FOR_END_19717__;$i+=1){ ?>
            <li name="page">
                <a href="#" page="<?php echo $i; ?>"><?php echo $i; ?></a>
            </li>
            <?php } ?>
        </ul>
    </div>
</div> <!-- /widget-body -->
<script src="/back/public/static/assets/js/jquery.min.js"></script>
<script>
    function search(){
    $("[name='Search']").on("change", function () {
        console.log($(this).val());
        let key = $(this).val();
        let length = $("[name = 'users_length']").val();
        location.href = "<?php echo url('User/search'); ?>?key="+key;
    });
    }

    search();
    $("[name='Search']").on("focus", function () {
        $("[name = 'pagelist']").hide();
    });
    $("[name='Search']").on("blur", function () {
        $(this).val("");
        $("[name = 'pagelist']").show();
    });
    $("[name = 'users_length']").on("change", function () {
        console.log($(this).val());
        const length = $(this).val();
        $("[name = 'pagelist']").empty();
        for (let i = 0; i < Math.ceil($("[name = 'pagelist']").attr("pagenum") / length); i++) {
            var newli = document.createElement('li');
            var p = `<li name="page">
                        <a href="#" page="${i+1}">${i+1}</a>
                    </li>`;
            newli = p;
            $("[name = 'pagelist']").append(newli);
        };
        clicka();
        $.ajax({
            type: 'post',
            url: "<?php echo url('User/limit'); ?>",
            data: {
                "lenth": length
            },
            success: function (data) {
                let json = JSON.parse(data);
                // console.log(json);
                $('.userlist').empty();
                for (let index = 0; index < json.length; index++) {
                    const element = json[index];
                    var newb = document.createElement('tr');
                    var b = `                
                            <td>${element.name}</td>
                            <td>${element.sNumber}</td>
                            <td>${element.teleNumber}</td>
                            <td>${element.schoolName}</td>
                            <td>
                                <span class="label label-success slabel" data-uid="${element.userId}" data-status='0'>正常</span>
                            </td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                                        操作
                                        <span class="caret"></span>
                                    </a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href="resetpw?uid=${element.userId}"><i class="icon-wrench"></i> 重置密码</a>
                                        </li>
                                        <li><a href="edituser?uid=${element.userId}"><i class="icon-edit"></i> 修改</a></li>
                                        <li><a href="deluser?uid=${element.userId}"><i class="icon-trash"></i> 删除</a></li>
                                    </ul>
                                </div>
                            </td>`;
                    newb.innerHTML = b;
                    $('.userlist').append(newb);
                }
            },
            error: function (error) {
                console.log(error);
            }
        });

    })

    clicka();

    function clicka() {
        $("a[page]").on('click', function () {
            console.log($(this).attr("page"));
            let clickPage = $(this).attr("page");
            let length = $("[name = 'users_length']").val();
            $.ajax({
                type: 'post',
                url: "<?php echo url('User/pageselector'); ?>",
                data: {
                    "page": clickPage,
                    "lenth": length,
                },
                success: function (data) {
                    let json = JSON.parse(data);
                    // console.log(json);
                    $('.userlist').empty();
                    for (let index = 0; index < json.length; index++) {
                        const element = json[index];
                        var newb = document.createElement('tr');
                        var b = `                
                            <td>${element.name}</td>
                            <td>${element.sNumber}</td>
                            <td>${element.teleNumber}</td>
                            <td>${element.schoolName}</td>
                            <td>
                                <span class="label label-success slabel" data-uid="${element.userId}" data-status='0'>正常</span>
                            </td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                                        操作
                                        <span class="caret"></span>
                                    </a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href="resetpw?uid=${element.userId}"><i class="icon-wrench"></i> 重置密码</a>
                                        </li>
                                        <li><a href="edituser?uid=${element.userId}"><i class="icon-edit"></i> 修改</a></li>
                                        <li><a href="deluser?uid=${element.userId}"><i class="icon-trash"></i> 删除</a></li>
                                    </ul>
                                </div>
                            </td>`;
                        newb.innerHTML = b;
                        $('.userlist').append(newb);
                    }
                }
            })
        })
    }
</script>

          </div> <!-- /widget -->
        </div> <!-- /row-fluid -->

      </div>
      <!-- /Main window -->

    </div>
    <!--/.fluid-container-->
  </div><!-- wrap ends-->

  <!-- Example Modal -->
  <div id="example_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
    aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">添加用户</h3>
    </div>
    <div class="modal-body">
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">重置</button>
      <button class="btn btn-primary">添加</button>
    </div>
  </div>

  <script src="/back/public/static/assets/js/jquery.min.js"></script>
  <script src="/back/public/static/assets/js/jquery-ui.min.js"></script>
  <script src="/back/public/static/assets/js/raphael-min.js"></script>
  <script src="/back/public/static/assets/js/bootstrap.js"></script>
  <script src='/back/public/static/assets/js/sparkline.js'></script>
  <script src='/back/public/static/assets/js/morris.min.js'></script>
  <script src="/back/public/static/assets/js/jquery.dataTables.min.js"></script>
  <script src="/back/public/static/assets/js/jquery.masonry.min.js"></script>
  <script src="/back/public/static/assets/js/jquery.imagesloaded.min.js"></script>
  <script src="/back/public/static/assets/js/jquery.facybox.js"></script>
  <script src="/back/public/static/assets/js/jquery.alertify.min.js"></script>
  <script src="/back/public/static/assets/js/jquery.knob.js"></script>
  <script src='/back/public/static/assets/js/fullcalendar.min.js'></script>
  <script src='/back/public/static/assets/js/jquery.gritter.min.js'></script>
  <script src="/back/public/static/assets/js/realm.js"></script>
</body>
<script>
  $(".slabel").on("click", function () {
    $(this).toggleClass("label-success");
    if ($(this).attr("data-status") == 1) {
      $(this).text("正常");
      $(this).attr("data-status", 0);
      $.ajax({
        type: 'post',
        url: "<?php echo url('User/status'); ?>",
        data: {
          "status": 0,
          "uid": $(this).attr("data-uid"),
        },
        //				dataType:"json",
        success: function (data) {
          console.log(data);
          if (data != "success")
            alert(data);
        },
        error: function (error) {
          alert(error);
        }
      });
    } else {
      $(this).text("禁用");
      $(this).attr("data-status", 1);
      $.ajax({
        type: 'post',
        url: "<?php echo url('User/status'); ?>",
        data: {
          "status": 1,
          "uid": $(this).attr("data-uid"),
        },
        //				dataType:"json",
        success: function (data) {
          console.log(data);
          if (data != "success")
            alert(data);
        },
        error: function (error) {
          alert("error");
        }
      });
      // $vo.status == 0;
    }
    console.log($(this).val());
  })
</script>


</html>
